/*
 * HttpBaseHeader.hpp
 *
 *  Created on: 09.12.2012
 *      Author: zheka
 */

#ifndef HTTPBASEHEADER_HPP_
#define HTTPBASEHEADER_HPP_

#include <map>
#include <string>
#include "util/StringUtils.hpp"
class HttpBaseHeader {
protected:
	std::map<std::string, std::string> headers;
	std::string httpVersion;

public:
	virtual void addHeader(const std::string & key, const std::string & value);
	virtual std::string toString() const;
	void setHttpVersion(const std::string & httpVersion);
	size_t getContentLength() 	const {
			std::map<std::string, std::string>::const_iterator it = headers.find(
						"Content-Length");
			if(it == headers.end()) {
				throw 1;
			}
			return StringUtils::toInteger(it->second);
		}
	 std::string  getHeader(const std::string & key) const {
		std::map<std::string, std::string>::const_iterator it = headers.find(
								key);
		if(it == headers.end()) {
						 return "";
					}
		return it->second;
	}
};

#endif /* HTTPBASEHEADER_HPP_ */
